define(['validate','Datetimepicker'],function (validate,datetimepicker) {
    $.validator.setDefaults({
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-group').removeClass('has-error').addClass('has-success');
        },
        errorElement: "span",
        errorPlacement: function (error, element) {
            if (element.is(":radio") || element.is(":checkbox")) {
                error.appendTo(element.parent().parent().parent());
            } else {
                error.appendTo(element.parent());
            }
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
    $.fn.datetimepicker.dates['zh-CN'] = {
        days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
        daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
        daysMin:  ["日", "一", "二", "三", "四", "五", "六", "日"],
        months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        today: "今天",
        suffix: [],
        meridiem: ["上午", "下午"]
    };
    return{
        init:function () {
            $(".addForm").validate({
                rules: {
                    userName: {
                        required: true,
                        minlength: 2
                    },
                    password: {
                        required: true,
                        minlength: 5
                    },
                    verifyPassword: {
                        required: true,
                        minlength: 5,
                        equalTo: "#password"
                    },
                    realName: {
                        required: true,
                    },
                },
                messages: {
                    userName: {
                        required:"请输入您的用户名",
                        minlength:"用户名必须两个字符以上"
                    },
                    password: {
                        required:"请输入您的密码",
                        minlength:"密码必须5个字符以上"
                    },
                    verifyPassword: {
                        required: "请再次输入密码",
                        minlength:"密码必须5个字符以上",
                        equalTo:"两次输入的密码不一致"
                    },
                    realName: {
                        required:"必须填写真实的姓名",
                    }
                }
            });
            datetimepicker.Datetimepicker($('input.timepicker'),{format: "yyyy-mm-dd hh:ii",
                todayBtn: true,
                minView:0,
            });
        }
    }
})